package mapred.config;

import java.io.IOException;

import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.mapred.JobConf;

public class JobConfig {

    private JobConf conf;

    public JobConfig() {
        this(new JobConf(JobConfig.class));
    }
    
    public JobConfig(JobConf conf) {
        this.conf = conf;
    }

    public String get(String key) {
        return conf.get(normalize(key));
    }

    private String normalize(String key) {
        return key.toLowerCase();
    }

    public FileSystem getFileSystem() throws IOException {
        return FileSystem.get(conf);
    }

    public JobConf getJobConf() {
        return conf;
    }

    public void set(String key, Object value) {
        conf.set(normalize(key), value.toString());
    }

    public String get(String key, Object defValue) {
        String ret = this.get(key);
        if (ret == null) {
            ret = defValue.toString();
        }
        return ret;
    }

}
